﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace Cqrs.StateMachineDesigner
{
    /// <summary>
    /// Interaction logic for InputBox.xaml
    /// </summary>
    public partial class InputBox : Window
    {
        public bool Accepted { get; private set; }
        public string Text { get; private set; }
        public InputBox()
        {
            InitializeComponent();
        }

        public bool ShowForm(string userMessage, string text = "")
        {
            grpText.Header = userMessage;
            Text = text;
            txtUserInput.Text = text;
            this.ShowDialog();
            return Accepted;
        }

        private void btnOK_Click(object sender, RoutedEventArgs e)
        {
            Accepted = true;
            Text = txtUserInput.Text;
            this.Close();
        }

        private void btnCancel_Click(object sender, RoutedEventArgs e)
        {
            Accepted = false;
            this.Close();
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            this.txtUserInput.Focus();
            this.txtUserInput.SelectAll();            
        }
    }
}
